#include"shmCom.hpp"
using namespace shm;

int main()
{
    myshm shmc(client);
    //shmc.BuildShm();
    std::cout<<shmc.getid()<<std::endl;
    std::cout<<shmc.getaddr()<<std::endl;
    shmc.Attach();
    char* str = (char*)shmc.getaddr();
    //char* tmp = "i am process A";
    char tmp[] = "i am process A";
    snprintf(str,sizeof(tmp)+2,"%s\n",tmp);
    sleep(5);
    shmc.RmShm();

    return 0;
}



    /*
    for(int i = 0;i < 26;i++)
    {
        str[i] = 'a'+i;
    }
    */
    //printf("%d\n",shmc.getid());





    /*
    int _shmid = 0;
    key_t key = ftok(path,key);
    printf("Key generated: %d\n", key);
    
    _shmid = shmget(key,512,IPC_CREAT | IPC_EXCL | 0666);
    if(_shmid == -1){
        perror("shmget");
        exit(1);
    }
    printf("BuildShm success\n");
    if(shmctl(_shmid,IPC_RMID,NULL)==-1)
    {
        perror("shmctl");
        exit(1);
    }
    printf("rmShm success\n");
    */